package com.zxy.supplier_system.server.controller

import com.zxy.supplier_system.server.entity.EmployeeOperateRecord
import com.zxy.supplier_system.server.service.EmployeeOperateRecordService
import com.zxy.supplier_system.server.utils.IntIdAndName
import org.springframework.data.domain.Page
import org.springframework.data.domain.Pageable
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
import java.time.OffsetDateTime

@RestController
@RequestMapping("employees/operationRecords")
class EmployeeOperateRecordController(
    private val employeeOperateRecordService: EmployeeOperateRecordService,
) {

    data class QueryEmployeeOperateRecordRequest(
        val operatorIds: List<Int> = emptyList(),
        val createdStartDate: OffsetDateTime?,
        val createdEndDate: OffsetDateTime?,
    )

    @GetMapping
    fun queryEmployeeOperateRecords(request: QueryEmployeeOperateRecordRequest,pageable: Pageable): Page<QueryEmployeeOperateRecordResponse> {
        return employeeOperateRecordService.queryEmployeeOperateRecords(request,pageable)
    }

    data class QueryEmployeeOperateRecordResponse(
        val content:List<EmployeeOperateRecord.ContentItem>,
        val id:Int,
        val createdDateTime: OffsetDateTime,
        val createdBy:IntIdAndName,
    )

}